<template>
  <div>
    <el-table :data="tableData" stripe border style="width: 100%">
      <el-table-column prop="createTime" label="创建时间" width="180"/>
      <el-table-column prop="taskName" label="任务名称" width="180"/>
      <el-table-column prop="address" label="申请人" v-model="person"/>
      <el-table-column label="操作">
        <el-button round type="primary" @click="look()">详情</el-button>
      </el-table-column>
    </el-table>

    <el-dialog
        v-model="dialogVisible"
        title="查看"
        width="40%">
      <el-form>
        <el-form-item label="天数">
          <el-input v-model="day"></el-input>
        </el-form-item>
        <el-form-item label="请假原因">
          <el-input type="textarea" v-model="reason"></el-input>
        </el-form-item>
        <el-form-item>
        </el-form-item>
      </el-form>
      <template #footer>
      <span class="dialog-footer">
        <el-button @click="dialogVisible = false" type="primary">关闭</el-button>
      </span>
      </template>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "historyName",
  data() {
    return {
      dialogVisible: false,
      tableData: [],
      reason: '',
      day: '',
      taskId: '',
      person:'测试账号'
    }
  },
  mounted() {
    this.axios.get("http://172.20.10.3:8080/history?userId=0").then(res => {
      console.log(res.data)
      if (res.status === 200) {
        this.tableData = res.data
        this.taskId = res.data[0].taskId
      }
    }).catch(() => {
      this.$message({
        message: "网络错误",
        type: 'error',
      })
    })

  },
  methods: {
    look() {
      this.axios.get("http://172.20.10.3:8080/processVariables?taskId=" + this.taskId).then(res => {
        console.log(res)
        this.day = res.data.days;
        this.reason = res.data.reason;
      })
      this.dialogVisible = true

    }
  }

}
</script>

<style scoped>

</style>
